package com.java.netty.log4j;

public class T5 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new ParentThread();
        t.start();
        Thread.sleep(1000);
        t.interrupt();
        t.join();
        System.out.println("end");
    }

    static class ParentThread extends Thread {
        public void run() {

            Thread hello = new ChildThread();
            hello.start();
            try {
                hello.join();
            } catch (
                    InterruptedException e) {
                System.out.println("interrupted!");
            }
        }
    }

    static class ChildThread extends Thread {
        public void run() {
            int n = 0;
            while (!isInterrupted()) {
                n++;
                System.out.println(n + "hello !");
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    break;
                }
            }
        }
    }
}



